@extends('layouts.tankuang')

@section('content')

        <div>
                        <div id="tb3" style="padding:3px">

                             @if(Auth::guard('admin')->user()->role_id == 22)
                            <a href="javascript:void(0)" class="easyui-linkbutton"  onclick="add()" plain="true" iconCls='icon-add'>新增</a>
                            <a href="javascript:void(0)" class="easyui-linkbutton"  onclick="edit()" plain="true" iconCls='icon-edit'>查看</a>
                            <a href="javascript:void(0)" class="easyui-linkbutton"  onclick="cancel()" plain="true" iconCls='icon-cancel'>删除</a>
                            <a href="javascript:history.back(-1)" class="easyui-linkbutton"   iconCls='icon-back'>返回</a>
                            @else
                            <a href="javascript:void(0)" class="easyui-linkbutton"  onclick="edit()"  plain="true" iconCls='icon-edit'>查看</a>
                            <a href="javascript:void(0)" class="easyui-linkbutton"  onclick="cancel()" plain="true" iconCls='icon-cancel'>删除</a>
                            @endif
                    

                        </div>
                        <table id="dg4" title="" class="easyui-datagrid" style="width:100%;height:600px" toolbar="#tb3"
                                data-options="rownumbers:true,singleSelect:true,pagination:true,pageSize:20,url:'{{url('admin/rysh/police',$id)}}',method:'get',toolbar:'#dg4'">
                            <thead>
                                <tr>
                                    <th data-options="field:'hcry'" width="40%" align="center">核查人员</th>
                                    <th data-options="field:'sbren'" width="20%"  align="center">上报人</th>
                                    <th data-options="field:'police_cl'" width="20%"  align="center">是否处理</th>
                                    <th data-options="field:'sbsj'" width="20%" align="center">上报时间</th>
                                    
                                </tr>
                            </thead>
                        </table>
                    </div>


            <script type="text/javascript">
                function edit(){
            //       var row = $('#dg1').datagrid('getSelected');
                    var parent = $(this).parent().next(".datagrid-view").children("table").attr("id");
                    var index =  $('#'+parent).datagrid('getRowIndex', $('#'+parent).datagrid('getSelected'));
                     if(index <0){
                        alert("提示, 请选中要编辑的行！")
                     }else{
                         console.log(index);
                     }
                     
                }
            </script>


            <!--如果处理了-->
            <script type="text/javascript">
                $('#dg4').datagrid({
                    rowStyler:function(index,row){
                        if (row.police_cl == '已处理'){
                            return 'background-color:#BEFDA3;color: #0992f5;font-weight:bold;';
                        }
                    }
                });

            </script>



        <!-- 考核新增弹框 -->
        <div id="adbg" class="easyui-window" title="添加" data-options="modal:true,closed:true,iconCls:'icon-save'" style="width:800px;height: auto;max-height:500px;padding:10px;">
       
        </div>


        <div id="dlg" class="easyui-dialog" title="删除" closed="true" style="width:400px;height:200px;line-height:100px;text-align:center;font-size:16px;padding:10px">
            您确定要删除该列表？
        </div>

		<script type="text/javascript" src="{{ URL::asset('/') }}js/weizhi.js"></script>
        <script type="text/javascript">
		
            function add(){
                $('#adbg').window({
                title: "新增",
                href: "addrysh",
                width:'800',
                height:'500',
                minimizable:false,
				top:($(window).height() - 500) * 0.5,
				left:($(window).width() - 800) * 0.5,
                modal:true,
                closed: false,
                });
            }



            function edit(){
            var row = $('#dg4').datagrid('getSelected');
            var shuz = fb2();
            if (row) {
                var url = '/admin/rysh/ryshedit/'+row.rysh_id;
                $('#adbg').window({
                    title: "查看",
                    href: url,
                    width:shuz[0],
					height:shuz[1],
					top:shuz[2],
					left:shuz[3],
                    minimizable:false,
                    modal:true,
                    closed: false,
                });
            }else {
                $.messager.alert('提示','请选中要查看的行！');
            }
          }


          function cancel(){
            var row = $('#dg4').datagrid('getSelected');
            if (row) {
                $('#dlg').dialog({
                    title: "注销",
                    closed: false,
                    top:($(window).height() - 200) * 0.5,
					left:($(window).width() - 400) * 0.5,
                    modal:true,
                    buttons: [{
                        text: '确定',
                        iconCls: 'icon-ok',
                        handler: zhuxiao
                    }, {
                        text: '取消',
                        iconCls: 'icon-cancel',
                        handler: function () {
                            $('#dlg').dialog('close');
                        }
                    }]
                });
            } else {
                $.messager.alert('提示','请选中要编辑的行！');
            }
        }

        function zhuxiao(){
            $('#dlg').dialog('close');
            var row = $('#dg4').datagrid('getSelected');
            var url = '/admin/rysh/del/'+row.rysh_id;
            $.ajax({
                type: 'get',
                url: url,
                success: function(data){
                    if(data.status == 1){
                        $.messager.alert('信息提示',data.msg,'info');
                      
                        var rowIndex = $('#dg4').datagrid('getRowIndex', row);
                        $('#dg4').datagrid('deleteRow', rowIndex);
                    }else{
                        $.messager.alert('信息提示',data.msg,'info');
                    }
                }
            });
        }


        $("#dg4").datagrid({
            onDblClickRow: function (index, row) {
                edit();
            }
        });


        </script>

@stop